FROM ubuntu:14.04

MAINTAINER GULL <gull@163.com>
ADD sources.list /etc/apt/sources.list

COPY config/* /tmp/

WORKDIR /root

# 安装软件
RUN apt-get update && \
    apt-get install -y openssh-server  && \
    apt-get install -y wget && \
    apt-get clean all && \
    wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.2.3/hadoop-3.2.3.tar.gz  && \
    wget --no-check-certificate  https://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.10.0/apache-flume-1.10.0-bin.tar.gz && \
    wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/Adoptium/8/jdk/x64/linux/OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz && \
    tar -xzvf OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz -C /usr/local/ && \
    tar -xzvf hadoop-3.2.3.tar.gz -C /usr/local/  && \
    tar -xzvf apache-flume-1.10.0-bin.tar.gz -C /usr/local/  && \
    mv /usr/local/jdk8u332-b09 /usr/local/jdk && \
    mv /usr/local/hadoop-3.2.3 /usr/local/hadoop && \
    mv /usr/local/apache-flume-1.10.0-bin /usr/local/flume && \
    rm -rvf /root/OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz && \
    rm -rvf /root/hadoop-3.2.3.tar.gz && \
    rm -rvf /root/apache-flume-1.10.0-bin.tar.gz


# set environment variable
ENV JAVA_HOME=/usr/local/jdk
ENV HADOOP_HOME=/usr/local/hadoop
ENV FLUME_HOME=/usr/local/flume
ENV PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$FLUME_HOME/bin

# ssh without key and hadoop config
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' && \
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && \
    mv /tmp/ssh_config ~/.ssh/config && \
    mv /tmp/hadoop-env.sh $HADOOP_HOME/etc/hadoop/hadoop-env.sh && \
    mv /tmp/flume-env.sh $FLUME_HOME/conf/flume-env.sh && \
    rm -rvf /usr/local/flume/lib/guava-11.0.2.jar && \
    cp /usr/local/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /usr/local/flume/lib/

CMD [ "sh", "-c", "service ssh start; bash"]

